<?php

class leagueTable {

var $html;
	
	function getLeagueData() {
		$db = new Connection();
			$html = "";
			$this->html .="<table class=\"leaguetable\">\n<tr><td>";
			$this->html .= "<b>League Table Top 10</b>";
			$this->html .="</td></tr>\n<tr><td><b>Username</b><hr /></td><td><b>Total Spend</b><hr /></td></tr>\n";
			
			$result = mysql_query("SELECT SUM(total_price) AS totalcost, user_name, lob, date FROM reports WHERE lob = '".$_SESSION['lob']."' AND MONTH(date) = MONTH(CURRENT_DATE) GROUP BY user_name ORDER BY totalcost DESC LIMIT 10") or die (mysql_error());
		
				//Display Retrieved information
				while($row = mysql_fetch_array( $result )) {
			
					$this->html .=  "<tr><td>".$row['user_name']."<hr /></td><td>";
					$this->html .= "&#163;".number_format($row['totalcost'], 2)."<hr /></td></tr>\n";
			
				}
				
				
			$this->html .= "</table>";
			
			}
			
								
	
	}

?>